﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using ElfTyping.General;
using ElfTyping.Animations;

namespace ElfTyping.States.GameState.Entities
{
    abstract public class Entity
    {
        protected const int Width = 50;
        protected const int Height = 50;

        protected GameScript Script { get; private set; }
        public Rectangle DrawBox { get; private set; }
        public Vector2 CenterPosition { get; private set; }
        protected Point CenterPoint { get { return new Point((int)CenterPosition.X, (int)CenterPosition.Y); } }
        protected Animation CurrentAnimation { get; set; }
        
        public Entity(GameScript script, Vector2 centerPosition)
        {
            Script = script;
            //Script.CallerEntity = this;

            MoveCenter(centerPosition);
        }

        public virtual void Draw(Camera camera)
        {
            CurrentAnimation.Draw(camera, DrawBox);
        }

        public virtual void Tick(float dt)
        {
            CurrentAnimation.Advance(dt);
        }

        public void MoveCenter(float x, float y)
        {
            MoveCenter(new Vector2(x, y));
        }

        public void MoveCenter(Vector2 newCenter)
        {
            CenterPosition = newCenter;
            Point centerPoint = CenterPoint;
            DrawBox = new Rectangle(centerPoint.X - Width / 2, centerPoint.Y - Height / 2, Width, Height);
            
        }
    }
}
